<template>
  <div class="news-music find-music-cpns" v-infinite-scroll="infiniteScroll">
    <div class="news-main">
      <div class="news-tog">
        <div>
          <el-button
            :class="[isTog ? 'active' : '']"
            size="small"
            round
            @click="togList"
            >新歌速递</el-button
          >
          <el-button
            :class="[isTog ? '' : 'active']"
            size="small"
            round
            @click="togAnchor"
            >新碟上架</el-button
          >
        </div>
      </div>
      <el-tabs v-model="activeName" @tab-click="handleClick" class="tabs">
        <el-tab-pane
          class="tabs-item"
          v-for="item in tabs"
          :key="item.name"
          :label="item.label"
          :name="item.name"
        ></el-tab-pane>
      </el-tabs>
      <page-music-table
        :contentTableConfig="contentTableConfig"
        :dataList="tabs[currentIndex].list.slice(0, showNum)"
        :lookShow="lookShow"
        :total="tabs[currentIndex].list.length"
        @handleShowAll="handleShowAll"
        v-show="isTog"
      >
        <template #image="scope">
          <el-image
            style="width: 40px; height: 40px"
            :src="$filters.formatImgSize(scope.row.album.picUrl, 50)"
            :preview-src-list="[
              $filters.formatImgSize(scope.row.album.picUrl, 200)
            ]"
          >
          </el-image>
        </template>
      </page-music-table>
      <page-music-ablum
        v-show="!isTog"
        :ablumCards="albums.slice(0, albumNum)"
      ></page-music-ablum>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import PageMusicTable from '@/components/page-find-music/page-news-music/page-music-table'
import PageMusicAblum from '@/components/page-find-music/page-news-music/page-music-ablum'
import { contentTableConfig } from './config/news-music'
import { InitDoing } from '../hook/news-music'

export default defineComponent({
  components: {
    PageMusicTable,
    PageMusicAblum
  },
  setup() {
    const {
      tabs,
      isTog,
      togList,
      togAnchor,
      activeName,
      handleClick,
      currentIndex,
      handleShowAll,
      lookShow,
      showNum,
      albums,
      albumNum,
      infiniteScroll
    } = InitDoing()

    return {
      isTog,
      togList,
      togAnchor,
      tabs,
      activeName,
      handleClick,
      contentTableConfig,
      currentIndex,
      handleShowAll,
      lookShow,
      showNum,
      albums,
      albumNum,
      infiniteScroll
    }
  }
})
</script>

<style scoped lang="less">
.news-music {
  width: 100%;
  padding-bottom: 30px;

  .news-main {
    width: 90%;
    margin: 0 auto;

    .news-tog {
      width: 100%;
      display: flex;
      justify-content: center;

      > div {
        border: 1px solid skyblue;
        border-radius: 26px;
      }
      .active {
        background: skyblue;
        color: #f5f5f7;
      }
      .el-button {
        border: none;
      }
      .el-button + .el-button {
        margin-left: 0;
      }
    }

    .new-album {
      display: flex;
      width: 95%;
      margin: 0 auto;
      justify-content: space-around;
      flex-wrap: wrap;
    }
  }
}
</style>
